﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Employee_ApplicantApplyVacancy : System.Web.UI.Page
{
    EmployeeMethord EM = new EmployeeMethord();
    string VacancyID = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            VacancyID = Request.QueryString["ID"].ToString();
            if (!Page.IsPostBack)
            {
                LoadData();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
    private void LoadData()
    {
        DataSet ds = EM.ReturnApplicantApplytoVacancy(VacancyID);
        DataTable table = ds.Tables[0];
        Session["app"] = ds;
        GridView1.DataSource = table.DefaultView;
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        DataSet dsCurrent = (DataSet)Session["app"];
        GridView1.DataSource = dsCurrent.Tables[0].DefaultView;
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        DataSet ds = EM.ReturnApplicantApplytoVacancyLike(VacancyID, txtSearch.Text, ddlTypeSearch.SelectedValue);
        DataTable table = ds.Tables[0];
        Session["app"] = ds;
        GridView1.DataSource = table.DefaultView;
        GridView1.DataBind();
    }
    protected void btnDisplay_Click(object sender, EventArgs e)
    {
        if (btnDisplay.Text.Equals("Applicant Satisfactory"))
        {
            DataSet ds = EM.ReturnApplicantApplytoVacancySatisfactory(VacancyID);
            DataTable tb = ds.Tables[0];
            Session["app"] = ds;
            GridView1.DataSource = tb.DefaultView;
            GridView1.DataBind();
            btnDisplay.Text = "View All applicant apply";
        }
        else
        {
            LoadData();
            btnDisplay.Text = "Applicant Satisfactory";
        }
    }
}